package com.naizhuai.ui.management.presenter;

import com.naizhuai.AppContext;
import com.naizhuai.network.Config;
import com.naizhuai.network.RetrofitServerFactory;
import com.naizhuai.network.apistore.SearchUserRequest;
import com.naizhuai.Model.db.user.PersonUserBean;
import com.naizhuai.util.RxUtils;

import java.util.List;

import rx.Observable;

/**
 * 处理公共搜索的类
 * Created by code_han on 2018/1/25.
 */

public class UserSearchDataApiStoreIml implements UserSearchDataApiStore {

    private static UserSearchDataApiStore INSTANCE = null;

    public static UserSearchDataApiStore getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new UserSearchDataApiStoreIml();
        }
        return INSTANCE;
    }


    @Override
    public Observable<List<PersonUserBean>> getUserByPhone(String companyId,String searchName,String phoneNumber) {
        return createBaseClass().getUserByPhone(companyId,searchName,phoneNumber)
                .compose(RxUtils.applySchedulers());
    }
    private SearchUserRequest createBaseClass() {
        return RetrofitServerFactory.create(AppContext.getInstance(), SearchUserRequest.class, Config.COMPANY_COMMON_BASE_URL);
    }

}
